package com.example.seakdreamandroid.sleepRecord;

import java.util.Calendar;

public class SleepRecord {
    private Calendar startTime = Calendar.getInstance();
    private Calendar endTime = Calendar.getInstance();
    private static final String[] dayStrOfWeek = new String[]{"星期天","星期一","星期二","星期三","星期四","星期五","星期六"};

    public Calendar getStartTime() {
        return startTime;
    }

    public Calendar getEndTime() {
        return endTime;
    }

    public long getDuration(){
        long startTime = this.startTime.getTimeInMillis();
        long endTime = this.endTime.getTimeInMillis();
        return (endTime - startTime)/(1000 * 60);
    }
    public String getFormatDate(){
        return startTime.get(Calendar.YEAR) + "." + (startTime.get(Calendar.MONTH)+1) + "." + startTime.get(Calendar.DAY_OF_MONTH);
    }
    public String getDayOfWeek(){
        return dayStrOfWeek[startTime.get(Calendar.DAY_OF_WEEK)-1];
    }
    public String getFormatStartTime() {
        return startTime.get(Calendar.HOUR_OF_DAY) + ":" + startTime.get(Calendar.MINUTE);
    }

    public String getFormatEndTime() {
        return endTime.get(Calendar.HOUR_OF_DAY) + ":" + endTime.get(Calendar.MINUTE);
    }

    public void setStartTime(int year,int month,int day,int hour,int minute,int second){
        startTime.set(year,month-1,day,hour,minute,second);
    }

    public void setEndTime(int year,int month,int day,int hour,int minute,int second){
        endTime.set(year,month-1,day,hour,minute,second);

    }
}
